package com.itheima.demo05;

public class FactorialDemo01 {
    public static void main(String[] args) {
        //使用递归求5的阶乘
        //阶乘形式：5！= 5 * 4 * 3 * 2 * 1
        //拆解
        //5! = 5 * 4!
        //4! = 4 * 3!
        //...
        //1! = 1 就是递归的结束条件
        System.out.println(getFactorial(5));
    }

    public static int getFactorial(int number){
        if (number == 1){
            return 1;
        }
        return number * getFactorial(number - 1);
    }
}
